package com.java110.mall.goods.bmo.shopDistributionMode.impl;

import com.java110.mall.goods.bmo.shopDistributionMode.IGetShopDistributionModeBMO;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.java110.intf.goods.IShopDistributionModeInnerServiceSMO;
import com.java110.dto.shop.ShopDistributionModeDto;
import org.springframework.http.HttpStatus;

import java.util.ArrayList;
import java.util.List;

@Service("getShopDistributionModeBMOImpl")
public class GetShopDistributionModeBMOImpl implements IGetShopDistributionModeBMO {

    @Autowired
    private IShopDistributionModeInnerServiceSMO shopDistributionModeInnerServiceSMOImpl;

    /**
     *
     *
     * @param  shopDistributionModeDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> get(ShopDistributionModeDto shopDistributionModeDto) {


        int count = shopDistributionModeInnerServiceSMOImpl.queryShopDistributionModesCount(shopDistributionModeDto);

        List<ShopDistributionModeDto> shopDistributionModeDtos = null;
        if (count > 0) {
            shopDistributionModeDtos = shopDistributionModeInnerServiceSMOImpl.queryShopDistributionModes(shopDistributionModeDto);
        } else {
            shopDistributionModeDtos = new ArrayList<>();
        }

        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) shopDistributionModeDto.getRow()), count, shopDistributionModeDtos);

        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);

        return responseEntity;
    }
    /**
     *
     *
     * @param  shopDistributionModeDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> getShopDistributionModeAll(ShopDistributionModeDto shopDistributionModeDto) {


        List<ShopDistributionModeDto>  shopDistributionModeDtos = shopDistributionModeInnerServiceSMOImpl.getShopDistributionModeAll(shopDistributionModeDto);

        ResultVo resultVo = new ResultVo((int) Math.ceil((double) 10 / (double) shopDistributionModeDto.getRow()), 10, shopDistributionModeDtos);

        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);

        return responseEntity;
    }

}
